package com.mxpio.erp.plm.service.impl;

import com.mxpio.erp.common.plm.entity.ProjectTaskComplete;
import com.mxpio.erp.common.plm.service.ProjectTaskCompleteService;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.jpa.query.Operator;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.Transient;
import java.util.List;

@Service
public class ProjectTaskCompleteServiceImpl extends BaseServiceImpl<ProjectTaskComplete> implements ProjectTaskCompleteService {
    @Override
    @Transactional
    public Result<?> find(String taskCode) {
        Criteria criteria = Criteria.create();
        Criteria criteria1 = criteria.addCriterion("taskCode", Operator.EQ, taskCode);
        List<ProjectTaskComplete> tasks = this.list(ProjectTaskComplete.class, criteria1);
        for (ProjectTaskComplete one : tasks){
            if (one.getIsAuditEnd().equals("0")){
                return Result.OK(one);
            }
        }
        return Result.error("未找到对应的申请单");
    }
}
